package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.*;

class BankService {
	

	public static boolean addClient(Bank bank, Client client) {

		int length = bank.clients.length;

		for (int i = 0; i < length; i++) {

			if(bank.clients[i] == null) {
				bank.clients[i] = client;
				return true;
			}
		}
			return false;
	}


	public static void printMaximumAmountToWithdraw(Bank bank) {

		int length = bank.clients.length;

		for (int i = 0; i < length; i++) {
			if (bank.clients[i] == null) {
				break;
			}

			System.out.printf("Client %s \n", bank.clients[i].getClientSalutation());
			
			if (bank.clients[i].sacc != null) {
				System.out.printf("balance: %.2f\n", bank.clients[i].sacc.getBalance());
			}
			if (bank.clients[i].chacc != null) {
				System.out.printf("balance with overdraft: %.2f\n", bank.clients[i].chacc.maximumAmountToWithdraw());
			}


		}
	}

}